home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
STOCHAIN.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-10-24
|
28KB
|
807 lines
PAGE 60,132
;program to chain and form DOS storage blocks
; Usage is: STOCHAIN
sb SEGMENT AT 0 ;map of storage block header paragraph
sbkind DB ' ' ;Type of storage block: M or Z
sbpsp DW 0 ;PSP segment address
sblength DW 0 ;SB length in paragraphs
sbfill DB 11 DUP(0) ;filler
ORG sbkind
pspretint DW ? ;int 20
pspmemsize DW ? ;size of memory in paragraphs
pspresv DB ?
ORG 5h
pspcalldosfunct DB ? ;long call to dos function dispatcher
pspdosfunct DD ? ;IP:CS of dos function dispatcher
ORG 0Ah
pspdosterminate DD ? ;IP:CS of:dos terminate
ORG 0Eh
pspdosctrlbreak DD ? ; ctrl break address
ORG 12h
pspdoscrtclerr DD ? ; critical error handler
ORG 18h
pspdosdefhandle DD 20 dup(?) ; DOS 2.0 - 20 file handles
; DOS 3.0 - default file handles
ORG 2Ch
pspenv DW ? ;segment address of environment
ORG 32h
psphandlecount DW ? ;number of handles in table (DOS 3.0)
ORG 34h
psphandles DW ? ;offset of handle table in CS (DOS 3.0)
ORG 50h
pspdosfunction DW ? ;invoke dos function dispatcher
ORG 5Ch
pspfcb1 DB ? ;first fcb
ORG 6Ch
pspfcb2 DB ? ;second fcb
ORG 80h
pspparm DB ? ;unformatted paramter area
ORG 0FFh
pspend EQU $
sb ENDS
code_seg SEGMENT
ASSUME CS:code_seg,DS:code_seg,ES:sb
cr equ 13
lf equ 10
myretint DW ? ;int 20
ORG 50h
mydosfunction DW ? ;invoke dos function dispatcher
ORG 100h
code PROC far
jmp program
db 'Copyright 1986 by Arnold B. Krueger GPW MI, 48236'
typestring proc near
push ax
mov ax,0900h
int 21h
pop ax
ret
typestring endp
getfirstsb PROC near ;get first storage block, ES will point to it
PUSH AX
PUSH BX
MOV AX,5200h
INT 21h ;ES:BX points to memory block anchor+2
DEC BX
DEC BX
MOV ES,ES:[BX] ;get first memory block address into ES
POP BX
POP AX
RET
getfirstsb ENDP
getnextsb PROC near
PUSH AX
MOV AX,ES ;get current paragraph
ADD AX,[SBLENGTH] ;add in number of paragraphs
INC AX ;add 1 for header
MOV ES,AX ;set new extra segment address
POP AX
RET
getnextsb ENDP
hexformat equ $
hexaddrhi dw 0
hexaddrlo dw 0
db ':0 '
hexdata dw 18 dup(0)
hexdataend db '*$'
hexend db '*'
crlf db cr,lf,'$'
indent db 5 dup(' '),'$'
asciizl proc near ;string, length in CX
; at ES:DI searched for 0h
;new length in CX
push ax
xor al,al ;search for zero
call charstrl
pop ax
ret
asciizl endp
charstrl proc near ;string length in CX
;string at ES:DI searched for char in AL
;new length in CX
push ax
push di ;save register
push cx ;save cx
repnz scasb ;do search
jcxz charsterror ;if cx exhausted, may be error
charsthit:
mov ax,cx ;save count remaining
pop cx ;restore old cx
sub cx,ax ;subtract length
dec cx ;knock off 1 for failed test
jcxz charstnull ;if zero length, error
clc ;clear carry flag
jmp charstexit ;and exit
charsterror:
dec di ;back up
cmp al,es:[di] ;check last byte
je charsthit ;if what we want, use it
pop cx ;pull off saved cx
charstnull:
stc ;set error flag
charstexit:
pop di ;restore registers
pop ax
ret
charstrl endp
hextocharlist db '0123456789ABCDEF'
hextochar PROC near ;AL (hex) -> AX (characters)
PUSH SI
PUSH DX
PUSH CX
PUSH AX
XOR DX,DX
AND AX,0fh ;isolate low nibble
ADD AX,offset hextocharlist
MOV SI,AX ;get address of character
MOV DH,[SI] ;get character
POP AX
AND AX,0f0h ;isolate high nibble
MOV CL,4
SHR AX,CL
ADD AX,offset hextocharlist
MOV SI,AX ;get address of character
OR DL,[SI] ;get character
MOV AX,DX
POP CX
POP DX
POP SI
RET
hextochar ENDP
Hexline proc near ;type paragraph at ES: in hex
push si
push cx
push ax
push es
pop ax
call hextochar ;get low byte
mov hexaddrlo,ax
push es
pop ax
mov al,ah ;get high byte
call hextochar
mov hexaddrhi,ax
xor si,si
mov di,offset hexdata
mov cx,4
hexparaloop: ;loop 4 times per paragraph
push cx
mov cx,4
hexwordloop: ;loop 4 times per doubleword
mov al,es:[si]
call hextochar
mov ds:[di],ax
inc di
inc di
inc si
loop hexwordloop
mov byte ptr ds:[di],' '
inc di
pop cx
loop hexparaloop
pop ax
pop cx
pop si
ret
hexline endp
chartype proc near ;type CX bytes at ES:DI if typable
stc ;possible error
jcxz chartypeexit ;if nothing to type, exit
push ax
push cx
push dx
push di
chartypeloop:
mov dl,es:[di]
cmp dl,126 ;printer/console
; cmp dl,254 ;console only
ja chartypefix
cmp dl,31
ja chartypeit
jmp chartypefix ;printer/c